/*
 * @Author: AuroCaffe 18509564594@163.com
 * @Date: 2025-06-16 19:29:15
 * @LastEditors: AuroCaffe 18509564594@163.com
 * @LastEditTime: 2025-07-19 10:47:43
 * @FilePath: \HuiLin\api\cart.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import {
	http,
	Method
} from "@/utils/request.js";

import api from "@/config/api.js";


/**
 * 获取购物车列表
 * @param 
 */
export function getCartList() {
	return http.request({
		url: '/cart',
		method: Method.GET,
	});
}

/**
 * 加入购物车
 * @param 
 */
export function AddCart(params) {
	return http.request({
		url: '/cart',
		method: Method.POST,
		data: params
	});
}


/**
 * 删除购物车某一项
 * @param 
 */
export function deleteGoods(id) {
	return http.request({
		url: `/cart/${id}`,
		method: "DELETE",
	});
}

/**
 * 更新购物车数量
 * @param 
 */
export function updateCartItem(data) {
	return http.request({
		url: `/cart/${data.cartId}`,
		method: "PUT",
		data: {
			quantity: data.num
		}
	});
}

/**
 * 清空购物车中已结算商品
 * @param {object} params { productIds: [] }
 */
export function clearCart(params) {
	return http.request({
		url: '/cart/clear',
		method: Method.POST,
		data: params
	});
}

/**
 * 获取支付参数
 * @param 
 */
export function ordersProduct(data) {
	return http.request({
		url: `/orders/multi-pay`,
		method: "POST",
		data
	});
}



/**
 * 支付
 * @param 
 */
export function payments(data) {
	return http.request({
		url: `payments/merge`,
		method: "POST",
		data
	});
}